package com.sali.DP;

import java.util.List;

/**
 * @author sali
 * @date 2025/5/4 20:12
 */
public class LeetCode_120 {

    public int minimumTotal(List<List<Integer>> triangle) {
        int row = triangle.size();

        int[] dp = new int[row + 1];

        for (int j = row - 1; j >= 0; j--) {
            for (int i = 0; i <= j; i++) {
                dp[i] = Math.min(dp[i], dp[i + 1]) + triangle.get(j).get(i);
            }
        }

        return dp[0];
    }

}
